<template>
    <el-form :model="nodeForm" status-icon :rules="rules" ref="nodeForm"
             label-width="150px"
             style="margin-top: 10px;color: #1f2d3d">
        <el-form-item class="form-label" label="行政村名" prop="subName">
            <el-col :span="19">
                <el-input v-model="nodeForm.subName" placeholder="行政村名"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="分类" prop="clazz">
            <el-col :span="19">
                <el-input v-model="nodeForm.clazz" placeholder="行政村名"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="联系人" prop="name">
            <el-col :span="19">
                <el-input v-model="nodeForm.name" placeholder="联系人"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="电话" prop="phone">
            <el-col :span="19">
                <el-input v-model="nodeForm.phone" placeholder="电话"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="经度" prop="X">
            <el-col :span="19">
                <el-input v-model="nodeForm.x" placeholder="经度" type="number"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
        <el-form-item class="form-label" label="维度" prop="Y">
            <el-col :span="19">
                <el-input v-model="nodeForm.y" placeholder="维度" type="number"
                          maxlength="20" autocomplete="off"></el-input>
            </el-col>
        </el-form-item>
    </el-form>
</template>

<script>
    import qs from "qs";

    export default {
        name: "NewNode",
        data() {
            return {
                nodeForm: {
                    id: '',
                    taskName: '',
                    clazz: '',
                    subName: '',
                    name: '',
                    phone: '',
                    x: '',
                    y: '',
                    type: ''
                },
                rules: {
                    Task_name: [],
                    remark: []
                }
            }
        },
        props: {
            type: {
                type: Number,
                default: -1
            },
            id: {
                type: Number,
                default: -1
            }
        },
        mounted() {
            if (this.id !== -1) {
                axios.post("/bjdzms/releaseSubtask/findById",
                    qs.stringify({
                        'id': this.id
                    })).then(res => {
                    this.nodeForm = res.data;
                });
            }
        },
        methods: {
            to(path) {
                this.$router.push({name: path});
            },
            submitForm() {
                if (this.id !== -1) {
                    this.nodeForm.id = this.id;
                    axios.post("/bjdzms/releaseSubtask/upd",
                        qs.stringify(this.nodeForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                } else {
                    this.nodeForm.type = this.type;
                    axios.post("/bjdzms/releaseSubtask/add",
                        qs.stringify(this.nodeForm)
                    ).then(res => {
                        this.$emit('updateData');
                    });
                }
            }
        }
    }
</script>

<style>
    .el-upload-dragger {
        height: 40px !important;
    }
</style>

<style scoped>
    .el-header {
        background: #EBEBEB;
        color: #e5e9ef;
        font-size: 2em;
        line-height: 80px;
        border: 5px solid #EBEBEB;
    }

    .el-main {
        background: #fff;
    }

    .el-container {
        height: 100%;
    }

    .el-form-item {
        width: 610px;
    }
</style>
